package responses

import (
	"github.com/gofiber/fiber/v2"
)

func Response(c *fiber.Ctx, err error) error {
	if err != nil {
		return BadRequestResponse(c, err)
	}
	return OkResponse(c)
}
func Created_Response(c *fiber.Ctx, model any, err error) error {
	if err != nil {
		return BadRequestResponse(c, err)
	}
	return Created_OkResponse(c, &model)
}
func BadRequestResponse(c *fiber.Ctx, err error) error {

	c.Status(fiber.StatusBadRequest)
	return c.JSON(fiber.Map{"error": err.Error()})
}

func OkResponse(c *fiber.Ctx) error {

	return c.SendStatus(fiber.StatusOK)
}
func Created_OkResponse(c *fiber.Ctx, model any) error {
	return c.Status(fiber.StatusCreated).JSON(&model)
}
